aiui.define(['jquery','element','pjax'], function($,element,pjax){
    var body = $('body'),
     ClassName = {
        wrapper:'.aiui-wrapper',
        collapsed:'is-collapsed',
        sideOpen:'is-open',
        menutitle:'aiui-menu-title',
        collapsed_menu_title:'.aiui-wrapper.is-collapsed .aiui-menu-title',
        menu:'.aiui-menu',
        open_menu_title:'.aiui-wrapper .aiui-menu-title',
        aiui_sidebar_inner:'.aiui-sidebar-inner',
        pjax_container:'#pjax-container'
    },
    Admin = {
        /**
         * 自动初始化
         */
        init:function(){
            var that = this;
            //初始化事件
            $('*[aiui-event]').on('click',function(e){
                e.stopPropagation();
                var name = $(this).attr('aiui-event');
                that.event[name]  && that.event[name].call(this, e)
            })
        },
        /**
         * 设置事件
         * @param {String} name 名称
         * @param {Function} fn 回调函数
         */
        on:function(name,fn){
            this.event[name] = fn;
        },
        /**
         * 事件管理器
         */
        event:{
            //显示隐藏方法
            showMenu:function(){
                var that = $(this);
                if(that.hasClass('is-active')) return;
                that.addClass('is-active').parent().siblings().find('a').removeClass('is-active');
                $(ClassName.aiui_sidebar_inner+'[data-menu='+that.data('menuid')+']').show().siblings().hide();
            },
            jumpUrl:function(e){
                var that = $(this),
                url = that.data('jump-url'),
                target=that.data('jump-type');
                if(target=='_pjax'){
                    $.pjax({url:url,container: ClassName.pjax_container})
                }
            },
        },
    }
    Admin.init();//自动初始化
    return Admin;
});